<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/12/1
  Time: 15:23
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <%@ include file="/WEB-INF/views/common/common.jsp"%>
    <script type="text/javascript">
        $(function(){
            //监听页面的keyup事件 回车登陆
            $(document.documentElement).on("keyup",function(e){
                if(e.keyCode==13){
                    //调用登录的funciton
                    submitForm();
                }
            })


        });
    </script>
</head>
<body>
<script type="text/javascript">
    function submitForm() {
        $("#loginForm").form("submit", {
            url : "login",
            success : function(data) {
                data = $.parseJSON(data);
                console.debug(data);
                if (data.success) {
                    location.href = "/main";
                } else {
                    $.messager.alert("温馨提示", data.message, "info", function() {
                        //console.debug($("input[name=username]"));
                        if (data.errorCode == -100) {// 用户名错误
                            $("input[name=username]").focus();
                        } else if (data.errorCode == -101) {// 密码错误
                            $("input[name=password]").focus();
                        }
                    });
                }
            }
        });
    }
    function resetForm() {
        $("#loginForm").form("clear");
    }
</script>

<div align="center" style="margin-top: 100px;">
    <div class="easyui-panel" title="CRM用户登陆" style="width: 350px; height: 190px;">
        <form id="loginForm" class="easyui-form" method="post">
            <table align="center" style="margin-top: 15px;">
                <tr height="20">
                    <td>用户名:</td>
                </tr>
                <tr height="10">
                    <td><input name="username" class="easyui-validatebox" required="true" value="admin" /></td>
                </tr>
                <tr height="20">
                    <td>密&emsp;码:</td>
                </tr>
                <tr height="10">
                    <td><input name="password" type="password" class="easyui-validatebox" required="true" value="xxxx" /></td>
                </tr>
                <tr height="40">
                    <td align="center"><a href="javascript:;" class="easyui-linkbutton" onclick="submitForm();">登陆</a> <a
                            href="javascript:;" class="easyui-linkbutton" onclick="resetForm();">重置</a></td>
                </tr>
            </table>
        </form>
    </div>
</div>
</body>
</html>
